varying vec3 N, L;
uniform float time;

float pointSize(vec4 loc)
{
float ptSize = length(loc);
return (10000.0/ptSize);
}



void main()
{

  float particleScale=1.0;
  particleScale=gl_Vertex.w*1.0;
  vec3 myNormal=gl_Normal;
  float sideNess= 1.0 / max(abs(myNormal.z),0.02);
  particleScale+= 0.000250 * sideNess;  
  
  //reset gl_Vertex coordinate or we create weird distortions!
  vec4 myVertex=gl_Vertex;
  myVertex.w=1.0;
 
  gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * myVertex;
  gl_PointSize= pointSize(gl_ModelViewMatrix * myVertex)*particleScale;
  
  vec4 V = gl_ModelViewMatrix * myVertex;
  N = gl_NormalMatrix * gl_Normal;
  
  L = gl_LightSource[0].position.xyz - V.xyz;
  
  //gl_FrontColor.rgb=gl_LightSource[0].position.xyz;
  
  gl_FrontColor=clamp(gl_Color, 0.0, 1.0);
}




